﻿using Guoc.BigMall.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Guoc.BigMall.WebService.Dto
{
   public class MemberAddressVo
    {
        public int Id { get; set; }
        public int MemberId { get; set; }

        public string AreaCode { get; set; }

        public string Province { get {
                return getAreaName(0);
            } }

        public string City
        {
            get
            {
                return getAreaName(1);
            }
        }

        public string County
        {
            get
            {
                return getAreaName(2);
            }
        }

        public bool IsDefault { get; set; }

        public string PostCode { get; set; }
        public string Name { get; set; }
        public string Tel { get; set; }

        public string AddressDetail { get; set; }

        public string Address { get {
                return this.AreaFullName + AddressDetail;
            } }

        /// <summary>
        ///  区域全名
        /// </summary>
        public string AreaFullName { get; set; }

        private string getAreaName(int index)
        {
            if (string.IsNullOrEmpty(AreaFullName)) {
                return "";
            }

            var data = this.AreaFullName.Split('-');
            if (data.Length < 3) {
                return "";
            }
            if (index < 0 || index > 2) {
                return "";
            }
            return data[index];

        }

    }
}
